home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / text / print / psutils.lha / psutils / showchar.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1999-08-29  |  2.7 KB  |  128 lines

  1. /*
  2. #!/bin/sh
  3. # showchar: show character with information
  4. #
  5. # Copyright (C) Angus J. C. Duggan 1991-1995
  6. # See file LICENSE for details.
  7. #
  8. # usage:
  9. #       showchar Font-Name Char-Name | lpr -Pprinter
  10. */
  11.  
  12. if ~arg() then do
  13.         parse source . . $0 .
  14.         echo "Usage: `basename "$0"` Font-Name Char-Name"
  15.         exit 1
  16. end
  17.  
  18. do i=22 to sourceline()
  19.     say sourceline(i)
  20. end
  21. exit
  22. %!
  23. % Get character metrics and bounding box for $1
  24. /ns 30 string def
  25. /fname /$1 def
  26. /cname /$2 def
  27. /fn fname findfont 1000 scalefont def
  28. /thin 0.7 def
  29. /reduction 2.0 def
  30.  
  31. /sn { ns cvs show } def
  32. /sc { (\()show exch sn (,)show sn (\))show } def
  33.  
  34. /Times-Roman findfont 10 scalefont setfont
  35.  
  36. 72 242 translate % one inch in, 3 1/2 inch up
  37. newpath 0 0 moveto
  38. gsave   % print character name
  39.    0 468 rmoveto
  40.    ($2 from font $1 displayed on `date` by `basename $0` 1.00 (C) AJCD 1991)
  41.    show 
  42. grestore
  43.  
  44. gsave
  45.    thin setlinewidth  % cross hairs
  46.    -9 0 rmoveto 18 0 rlineto
  47.    -9 -9 rmoveto 0 18 rlineto
  48.    stroke  % position info
  49.    -9 -9 moveto ((0,0)) stringwidth pop neg 0 rmoveto
  50.    ((0,0)) show
  51. grestore
  52.  
  53. % create encoding with a single character at all positions
  54. /MyEncoding 256 array def
  55.  
  56. 0 1 255 { % fill out with notdefs
  57.    MyEncoding exch cname put
  58. } for
  59.  
  60. fn dup length dict begin
  61.   {1 index /FID ne {def} {pop pop} ifelse} forall
  62.   /Encoding MyEncoding def
  63.   currentdict
  64. end /newfont exch definefont
  65. /fn exch def
  66. /en MyEncoding def
  67.  
  68. gsave  % draw character (enlarged)
  69.   .75 setgray
  70.   fn 1 reduction div scalefont setfont
  71.   (\000) show
  72. grestore
  73.  
  74. % show character info
  75. fn /Metrics known {
  76.    dup fn /Metrics get exch get 
  77.    dup type /arraytype eq {
  78.       dup length 2 eq
  79.       {1 get 0} {dup 2 get exch 3 get} ifelse
  80.    } {
  81.       round 0
  82.    } ifelse
  83. } {
  84.    gsave
  85.       fn setfont (\000) stringwidth round exch round exch
  86.    grestore
  87. } ifelse
  88. gsave   % show width
  89.    thin setlinewidth
  90.    2 copy
  91.    reduction div exch reduction div exch rlineto
  92.    gsave
  93.       1 1 rmoveto sc
  94.    grestore
  95.    -4 -3 rlineto 0 6 rmoveto 4 -3 rlineto
  96.    stroke
  97. grestore
  98.  
  99. gsave
  100.    gsave  % get bounding box
  101.       fn setfont
  102.       (\000) true charpath flattenpath pathbbox
  103.    grestore
  104.    thin setlinewidth
  105.    3 index reduction div  % put coords on top of stack
  106.    3 index reduction div
  107.    3 index reduction div
  108.    3 index reduction div
  109.    3 index 3 index moveto
  110.    gsave  % llx lly
  111.       0 -9 rmoveto 7 index 7 index sc
  112.    grestore
  113.    1 index 3 index lineto
  114.    gsave  % urx lly
  115.       0 -9 rmoveto 5 index 7 index sc
  116.    grestore
  117.    1 index 1 index lineto
  118.    gsave  % urx ury
  119.       0 9 rmoveto 5 index 5 index sc
  120.    grestore
  121.    3 index 1 index lineto
  122.    gsave  % llx ury
  123.       0 9 rmoveto 7 index 5 index sc
  124.    grestore
  125.    closepath stroke
  126. grestore
  127. showpage
  128.